package com.easy.facilitaterecycleadapter.adapter;

import android.support.v7.widget.RecyclerView;
import android.util.SparseArray;
import android.view.View;

import com.easy.facilitaterecycleadapter.R;

/**
 * Created by Sigthp-P-Department on 2018/5/7.
 */

public class BaseViewHodler extends RecyclerView.ViewHolder {
    private SparseArray<View> sparseArray;

    public BaseViewHodler(View itemView) {
        super(itemView);
        sparseArray=new SparseArray<>();
    }
    public <T extends View> T  getView(int id){
        View view = sparseArray.get(id);

        if(view == null){
            view = itemView.findViewById(id);
            sparseArray.put(id,view);
        }
        return (T)view;
    }

    public void setOnClickListener(View.OnClickListener listener){
        itemView.setOnClickListener(listener);
    }

    public void setOnLoogClickListener(View.OnLongClickListener listener){
        itemView.setOnLongClickListener(listener);
    }

}
